<template>
  <!-- 考勤统计 -->
  <el-container>
    <el-header>
      <div class="left-panel">
        <el-button type="primary" @click="exportAttendanceList"
          >导出考勤</el-button
        >
      </div>
      <div class="right-panel">
        <div class="right-panel-search">
          <el-date-picker
            v-model="searchValue.time"
            type="month"
            placeholder="请选择"
            style="width: 100%"
            value-format="YYYY-MM"
          />
          <!-- <el-input
            v-model="searchValue.search"
            placeholder="日程内容" 
            clearable
          ></el-input> -->
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="upsearch"
          ></el-button>
        </div>
      </div>
    </el-header>
    <el-main class="nopadding">
      <scTable
        ref="table"
        row-key="id"
        :apiObj="apiObj"
        :hidePagination="true"
        stripe
        @row-dblclick="handleRowDblclick"
        @filterType="filterType"
      >
        <el-table-column
          label="ID"
          prop="admin_id"
          width="50"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column label="姓名" prop="admin_name"> </el-table-column>
        <el-table-column label="应出勤(天)" prop="NormallyClock">
          <template #default="scope">
            <p>26天</p>
          </template>
        </el-table-column>
        <el-table-column label="实际出勤(天)" prop="shiji"></el-table-column>
        <!-- <el-table-column label="缺勤(天)" prop="createTime"></el-table-column> -->
        <el-table-column label="迟到(次)" prop="chidao"></el-table-column>
        <el-table-column label="早退(次)" prop="zaotui"></el-table-column>
        <el-table-column label="缺卡(次)" prop="queka"></el-table-column>
        <el-table-column label="请假(次)" prop="qingjia"></el-table-column>
      </scTable>
    </el-main>
  </el-container>
</template>

<script>
import { exportFile } from '@/utils/exportFile'
export default {
  name: 'attendance',
  data () {
    return {
      dialog: {
        save: false,
      },
      apiObj: this.$API.attendance.getAttendanceList,
      params: { time: '' },
      list: [],
      searchValue: {
        time: this.$TOOL.dateFormat(new Date(), 'yyyy-MM')
      }
    }
  },
  mounted () {
    // this.getList()
  },
  methods: {
    async getList () {
      let data = {
        time: this.searchValue.time
      }
      let res = await this.$API.attendance.getAttendanceList.get(data)
      this.list = res.data
      this.list.splice(-1, 1)

    },
    //搜索
    upsearch () {
      this.$refs.table.upData(this.searchValue)
      // this.getList()
    },
    filterType (data) {
      let tableData = data
      tableData.splice(-1, 1)

    },
    // 双击表格
    handleRowDblclick (row) {
      this.$router.push({
        path: '/reportForm/attendanceList/attendanceItem',
        query: {
          id: row.admin_id
        }
      })
    },
    // 导出
    async exportAttendanceList () {
      let res = await this.$API.attendance.exportAttendanceList.get({ time: this.searchValue.time })
      console.log(res)
      exportFile(res, '考勤统计.xls')
    }
  }
}
</script>

<style lang='scss' scoped>
</style>
